home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
bootany.zip
/
BSTRAP.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-29
|
16KB
|
339 lines
page 61,132
title Bstrap - update fixed disk bootstrap
subttl Code
page +
Code segment
assume cs:Code, ds:Code, es:Code, ss:Code
org 80h
parmLen db ?
parm db ?
org 100h
include bootany.inc
Bstrap proc far
mov SI,DS ; Get data segment
mov ES,SI ; Make sure the same
;
; Read current bootstrap record
;
mov AX,201h ; read 1 sector
lea BX,Boot ; buffer address
mov CX,1 ; cyl 0, sector 1
mov DX,80h ; head 0, drive 0
int 13h ; read fixed disk boot
jnc ReadOk ; Go on if ok
mov bx,2 ; write to stderr
mov cx,Err1l ; length of message
lea dx,Err1 ; message address
mov ah,40h ; write to stream
int 21h ; send message
jmp Exit ; Exit program
ReadOk:
;
; Read in file named as parm (boot program)
; First find the program name
;
sub CX,CX ; clear register
sub SI,SI ; clear register
mov CL,parmLen ; Get length of parm
cmp CL,0 ; Better be there
jbe NameError ; its not
lea DI,parm ; get name address
mov AL,' ' ; what we will ignore
repe scasb
jcxz NameError ; No parm - write msg
jmp NameThere ; it is
NameError:
mov bx,2 ; write to stderr
mov cx,NameErrl ; length of message
lea dx,NameErr ; message address
mov ah,40h ; write to stream
int 21h ; send message
jmp Exit
;
; Found the name - Open and Read the file
;
NameThere:
dec DI ; Point to first byte
inc CX ; Correct the count
mov BX,CX ; get bytes left
mov [BX+DI],BYTE PTR 0 ; move in terminator
mov DX,DI ; Get file name start
sub AL,AL ; Open for read
mov AH,3dh ; Open function
int 21h ; Call DOS
jc FileError
lea DX,Boot ; buffer address
mov CX,PartAddr ; maximum boot length
mov BX,AX ; read from file
mov AH,3fh ; read from stream
int 21h ; dos service
jnc FileOk ; continue if file ok
FileError:
mov AH,3Eh ; Close the file
int 21h ; dos service
mov BX,2 ; write to stderr
mov CX,Err2l ; length of message
lea DX,Err2 ; message address
mov AH,40h ; write to stream
int 21h ; send message
jmp Exit ; Exit program
;
; The new boot program is not in our "in-memory" copy of the
; boot sector
;
FileOk:
;
; Close the file
;
mov AH,3Eh ; Close the file
int 21h ; dos service
;
; Update the boot sector with User Data
; Put out first message
;
mov bx,2 ; write to stderr
mov cx,Msg1l ; length of message
lea dx,Msg1 ; message address
mov ah,40h ; write to stream
int 21h ; send message
mov CX,max_partitions ; get loop count
PartLoop:
;
; Find out what partition this Function Key will be for
;
mov Index,CX ; Save index
sub CL,max_partitions+1 ; get negative index
neg CL ; turn positive
add CL,Numeric ; make displayable
mov Q1FKey,CL ; move into message
mov Q2FKey,CL ; move into message
mov Q3FKey,CL ; move into message
mov AL,max_partitions ; get max value
add AL,Numeric ; make displayable
mov Q1Max,AL ; move into message
mov BX,2 ; write to stderr
mov CX,Q1l ; length of message
lea DX,Q1 ; message address
mov AH,40h ; write to stream
int 21h ; send message
call GetChar ; Get the number
cmp AL,'0' ; See if '0'
jne NoExit ; If not continue
jmp TestNumLock ; Exit loop
NoExit:
cmp AL,'1' ; See if valid value
jl PartError ; No - reprompt
cmp AL,Numeric+max_partitions ; Check max value
ja PartError ; Too big - reprompt
mov Q2Pnum,AL ; Save part number
mov Err3P,AL ; Save part number
sub AL,Numeric+1 ; Turn into index
push AX ; Save for later
mov AH,SIZE PartData ; Get entry size
mul AH ; Get offset into table
mov Data,AX ; Get data address
mov BX,AX ; Get data address
pop AX ; Restore value
mov AH,SIZE PartitionEntry ; Get entry size
mul AH ; Get offset into table
mov Entry,AX ; Get entry address
cmp part.partition[BX],0 ; Already in use?
je BootTest ; No - use it
mov BX,2 ; write to stderr
mov CX,Err3l ; length of message
lea DX,Err3 ; message address
mov AH,40h ; write to stream
int 21h ; send message
PartError:
mov CX,Index ; restore index
jmp Partloop
BootTest:
; Check to see if the partition is marked bootable -
; If not, see if it should be made bootable
;
mov BX,Entry ; Get Entry address
cmp partitionTable.BootIndicator[BX],0 ; Can partition boot
jne PartBoot ; Yes - use it
push AX ; Save for later
mov BX,2 ; write to stderr